<?php 
	global $hasLog;
	$hasLog = ($this->user->hasLogin())? 1 : 0 ;
	function threadedComments($comments, $singleCommentOptions) {
        
		global $hasLog;
        $commentClass = '';
        if ($comments->authorId) {
                if ($comments->authorId == $comments->ownerId) {
                        $commentClass .= ' comment-by-author';
                } else {
                        $commentClass .= ' comment-by-user';
                }
        } 
        
        $commentLevelClass = $comments->_levels > 0 ? ' comment-child' : ' comment-parent';

?>
<li id="<?php $comments->theId(); ?>" class="comment-body<?php
    if ($comments->levels > 0) {
        echo ' comment-child';
        $comments->levelsAlt(' comment-level-odd', ' comment-level-even');
    } else {
        echo ' comment-parent';
    }
    $comments->alt(' comment-odd', ' comment-even');
    echo $commentClass;
?>">
	<div class="comment-author">
		<?php $comments->gravatar($singleCommentOptions->avatarSize, $singleCommentOptions->defaultAvatar); ?>
		<cite class="fn">
			<span class="ua_author"><?php $singleCommentOptions->beforeAuthor();$comments->author();$singleCommentOptions->afterAuthor(); ?></span> 
		</cite>
	</div>
	<div class="comment-meta"><a href="<?php $comments->permalink(); ?>"><?php $singleCommentOptions->beforeDate();$comments->date($singleCommentOptions->dateFormat);$singleCommentOptions->afterDate(); ?></a>
</div>
	<?php echo quote_change($comments->content); ?>
	<div class="comment-reply">
	<?php if($hasLog): ?>
		[<?php $comments->reply($singleCommentOptions->replyWord); ?>] | 
	<?php endif; ?>	
		[<a href="#response" rel="nofollow" onclick="return reply('<?php $comments->author(false);?>','<?php $comments->theId(); ?>')">引用</a>]	
	</div>
    <div class="clear"></div>
    <?php if ($comments->children) { ?>
    <div class="comment-children">
        <?php $comments->threadedComments($singleCommentOptions); ?>
    </div>
    <?php } ?>
</li>
<?php
    }
?>
<script type="text/javascript" src="<?php $this->options->themeUrl('js/re.js'); ?>" /></script>
<div id="comments">
			<?php $this->comments()->to($comments); ?>
			<?php if ($comments->have()): ?>
			<div id="comments-info"><?php $this->commentsNum(_t('现在还没评论'), _t('现在有 1 条评论啦'), _t('已经有 %d 条评论啦')); ?> &raquo;</div>

			<?php $comments->listComments(); ?>

			<?php endif; ?>

			<?php if($this->allow('comment')): ?>

			<ol id="commpagenavi">
				<?php $comments->pageNav(); ?>
			</ol>


			<div id="<?php $this->respondId(); ?>" class="respond">

			<?php if ($comments->have()): ?><div class="border"></div><?php endif; ?>

			<div class="cancel-comment-reply">
			<?php $comments->cancelReply(); ?>
			</div>

			<div id="response">打劫！！留下你的评论 &raquo;</div>
			<form method="post" action="<?php $this->commentUrl() ?>" id="comment_form">
				<?php if($this->user->hasLogin()): ?>
				<p>Logged in as <a href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> &raquo;</a></p>
				<?php else: ?>
                <div id="real-avatar">
					<img alt='' src='http://0.gravatar.com/avatar/?d=identicon&amp;s=40' class='avatar avatar-40 photo avatar-default' height='40' width='40' />
        		</div>
				<p>
					<input type="text" name="author" id="author" class="text" size="15" value="<?php $this->remember('author'); ?>" />
					<label for="author">呢称(必填的噢！)<span class="required">*</span></label>
				</p>
				<p>
					<input type="text" name="mail" id="mail" class="text" size="15" value="<?php $this->remember('mail'); ?>" />
					<label for="mail">Email(留下吧,只有博主才看得见)<?php if ($this->options->commentsRequireMail): ?><span class="required">*</span><?php endif; ?> [ <a href="http://en.gravatar.com/" target="_blank">更换头像</a> ]</label>
				</p>
                 <script type="text/javascript" src="<?php $this->options->themeUrl('js/realgravatar.js'); ?>" /></script>
				<p>
					<input type="text" name="url" id="url" class="text" size="15" value="<?php $this->remember('url'); ?>" />
					<label for="url">地址(有空我会回访的)<?php if ($this->options->commentsRequireURL): ?><span class="required">*</span><?php endif; ?></label>
				</p>
                <?php //Rfilter_Plugin::output(); ?>
				<?php endif; ?>
				<p>
					<textarea rows="5" cols="50" name="text" class="textarea" id="comment" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('misubmit').click();return false};"><?php $this->remember('text'); ?></textarea>
				</p>
				<p><input type="submit" value="提交评论(Ctrl+Enter)" class="submit" id="misubmit"/><label id="webmail"><input type="checkbox" name="banmail" id="banmail" value="stop" checked="checked"/>有回复时不要发送邮件给我</label></p>
			</form>
			</div>
			<?php else: ?>
			<h4>好好看吧，评论被那个家伙关掉了</h4>
			<?php endif; ?>
		</div>
